module MoneysHelper
  def about_draw_money
    '连续领取每天+5，连续7天以上每天+40，如中断领取，又会从5开始'
  end
  
  def feed_to_html(feed)
    template = highlight(feed.to_t,':user', :highlighter => user_in_feed_template(feed))
    template = highlight(template,':created_at_ago_in_words', :highlighter => created_at_ago_in_words_in_feed_tempalte(feed))
    template = highlight(template,':link_to_daily_draw', :highlighter => link_to_daily_draw_in_feed_template(feed))
    template = highlight(template,':link_to_bind_fetion', :highlighter => link_to_bind_fetion_in_feed_template(feed))
    template = highlight(template,':bounty_of_introduce_to_join', :highlighter => link_to_bounty_of_introduce_to_join_in_feed_template(feed))    
    template = highlight(template,':bounty_of_introduce_to_bind_fetion', :highlighter => link_to_bounty_of_introduce_to_bind_fetion_in_feed_template(feed))  
    template = highlight(template,':introducedor', :highlighter => link_to_introducedor_in_feed_template(feed))  
    template = highlight(template,':link_to_edit_user_logo', :highlighter => link_to_edit_user_logo_in_feed_template(feed))    
    template = highlight(template,':added_money', :highlighter => added_money_in_feed_template(feed))    
    template = highlight(template,':subed_money', :highlighter => subed_money_in_feed_template(feed))    
    template = highlight(template,':link_to_gift', :highlighter => link_to_gift_in_feed_template(feed))
    template = highlight(template,':tool', :highlighter => tool_in_feed_template(feed))    
    template = highlight(template,':rmb', :highlighter => rmb_in_feed_template(feed))    
    template = highlight(template,':mts_shop_in_taobao', :highlighter => mts_shop_in_taobao_in_feed_template(feed))    
    template = highlight(template,':consume_type', :highlighter => consume_type_in_feed_template(feed))    
    template = highlight(template,':link_to_edit_user_sex', :highlighter => edit_sex_in_feed_template(feed))
  end
  
  def rmb_in_feed_template(feed)
    "<b>#{feed.rmb}</b>元"
  end
  
  def consume_type_in_feed_template(feed)
    link_to "#{feed.consume_type}", "http://mytusi.taobao.com/?userId=&shopId=64737478&view_type=&order_type=&search=y&keyword=#{ to_taobao_uri(feed.consume_type)}&price1=&price2=",:target => :_blank,:class => 'feed user',:title => "去麦吐司的淘宝店看看：）"
  end
  
  def edit_sex_in_feed_template(feed)
    link_to "设置个人基本资料-性别", edit_user_url(feed.user),:target => :_blank,:class => 'feed user',:title => "赶紧设置：）"
  end
  
  def mts_shop_in_taobao_in_feed_template(feed)
    link_to "麦吐司淘宝店", "http://mytusi.taobao.com",:target => :_blank,:class => 'feed user',:title => "出售全国移动联通电信话费、游戏点卡、腾讯Q币、腾讯会员、腾讯钻"
  end
  
  def user_in_feed_template(feed)
    link_to truncate(feed.user.nick_name,:length => 5) , user_url(feed.user),:target => :_blank,:class => 'feed user',:title => feed.user.nick_name
  end
  
  def link_to_introducedor_in_feed_template(feed)
    feed.introducedor.present? ? link_to(truncate(feed.introducedor.nick_name,:length => 5), user_url(feed.introducedor),:target => :_blank,:class => 'feed user',:title => feed.introducedor.nick_name) : ''
  end
  
  def created_at_ago_in_words_in_feed_tempalte(feed)
    time_ago_in_words feed.created_at, false
  end
  
  def link_to_daily_draw_in_feed_template(feed)
    link_to '领取', money_url(feed.user), :target => :_blank,:class => 'feed daily_draw', :title => feed.user.has_drawn_money? ? "已经连续领取#{feed.user.draw_money_duration_days},明日可以领取#{feed.user.how_much_can_be_drawn_tomorrow_if_drawn_today}麦粒" : "已经连续领取#{feed.user.current_draw_money_duration_days},今日可以领取#{feed.user.how_much_can_be_drawn}麦粒"
  end
  
  def link_to_bind_fetion_in_feed_template(feed)
    link_to '绑定', user_url(:default),:target => :_blank,:class => 'feed user',:title => '绑定飞信'
  end
  
  def link_to_gift_in_feed_template(feed)
    feed.info.present? ? link_to('领取', money_url(:default), :target => :_blank,:class => 'feed gift', :title => "领取#{feed.info.money}麦粒大礼包") : ''
  end
  
  def link_to_bounty_of_introduce_to_join_in_feed_template(feed)
    link_to '介绍费', money_url(:default), :target => :_blank,:class => 'feed gift', :title => '介绍费'
  end
  
  def link_to_bounty_of_introduce_to_bind_fetion_in_feed_template(feed)
    link_to '高额介绍费', money_url(:default), :target => :_blank,:class => 'feed gift', :title => '高额介绍费'
  end
  
  def link_to_edit_user_logo_in_feed_template(feed)
    link_to '设置了头像', edit_user_url(:default), :target => :_blank,:class => 'feed edit_user', :title => '设置个性化的头像'
  end
  
  def added_money_in_feed_template(feed)
    "<b class='added'>#{feed.added_money}</b>"
  end
  
  def subed_money_in_feed_template(feed)
    "<b class='subed'>#{feed.subed_money}</b>"
  end
  
  def tool_in_feed_template(feed)
    feed.tool.present? ? link_to(feed.tool.name, tool_url(feed.tool), :target => :_blank,:class => "feed tool", :title => feed.tool.title) : ''
  end
end
